package com.edu.zju.scs.panacea.service;

import com.edu.zju.scs.panacea.entity.resource.Dev;
import com.edu.zju.scs.panacea.entity.resource.Position;
import com.edu.zju.scs.panacea.mapper.resource.DevMapper;
import com.edu.zju.scs.panacea.service.resource.DevService;
import com.edu.zju.scs.panacea.utils.MathUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: Yue Liang
 * @Date: 2019-02-13 19:05
 */
@Service
public class TestService {

    @Autowired
    private DevService devService;

    public void insertTestDevData() {
        Position position1 = new Position();
        position1.setCountry("中国");
        position1.setProvince("北京");
        position1.setCity("北京市");
        position1.setDistrict("西城区");


        Position position2 = new Position();
        position2.setCountry("中国");
        position2.setProvince("浙江省");
        position2.setCity("杭州市");
        position2.setDistrict("西湖区");
        for (int i = 0; i < 10; i++) {
            Dev dev = new Dev();
            dev.setType(0);
            dev.setProbeId("DC4F22888612");
            dev.setLatitude(139.89f);
            dev.setLongitude(40.67f);
            dev.setSiteId(2l);
            dev.setName("设备7" + MathUtil.RandomSixBit());
            dev.setOwnId(MathUtil.RandomSixBit().toString());
            dev.setWidth(200);
            dev.setHeight(200);
            devService.addDev(dev, position1);
        }

        for (int i = 0; i < 10; i++) {
            Dev dev = new Dev();
            dev.setType(0);
            dev.setProbeId("DC4F22888612");
            dev.setLatitude(139.89f);
            dev.setLongitude(40.67f);
            dev.setSiteId(2l);
            dev.setName("设备" +  MathUtil.RandomSixBit());
            dev.setOwnId(MathUtil.RandomSixBit().toString());
            dev.setWidth(200);
            dev.setHeight(200);
            devService.addDev(dev, position2);
        }
    }
}
